package com.design.pattern.ornament.instance;

import com.design.pattern.ornament.base.Beverage;
import com.design.pattern.ornament.base.Condiment;

/**
 * @author wangyingjie
 * @date
 * @remark 摩卡咖啡(调料装饰者)
 */
public class MoCha extends Condiment {
    Beverage beverage;//被装饰者饮料基类

    public MoCha(Beverage beverage) {
        this.beverage = beverage;
    }

    /**
     * 增强计价方法，原价基础上增加0.2
     * @return
     */
    @Override
    public double cost() {
        return beverage.cost()+0.2;
    }

    @Override
    public String getDescription() {
        return beverage.getDescription()+" and Mocha";
    }

    public static void main(String[] args) {
        Espresso espresso = new Espresso();
        //用摩卡去装饰普通浓缩咖啡
        MoCha moCha = new MoCha(espresso);
        System.out.println(moCha.cost());
        System.out.println(moCha.getDescription());
    }
}
